#ifndef MAIN_GUI_H_
#define MAIN_GUI_H_

#include <Etk.h>
#include <Ecore_File.h>
#include <sylph/sylmain.h>
#include <sylph/account.h>
#include <sylph/prefs_common.h>
#include <sylph/procheader.h>

typedef struct _Main_Gui {
    Etk_Widget *win;
    Etk_Widget *vbox;
    Etk_Widget *hpaned;
    Etk_Widget *vpaned;
    Etk_Widget *menu_bar;
    Etk_Widget *menu_item, *popup_menu_item;
    Etk_Widget *menu;
    Etk_Widget *toolbar;
    Etk_Widget *toolbar_button;
    Etk_Widget *separator;
    Etk_Widget *messagebody_scroll;
    Etk_Tree_Col *mail_folders;
    Etk_Tree_Col *messages;
    Etk_Tree_Col *messages_has_attchment;
    Etk_Tree_Col *messages_subj;
    Etk_Tree_Col *messages_from;
    Etk_Tree_Col *messages_date;
    Etk_Widget *message_vbox;
    Etk_Widget *folder_tree, *message_tree;
    Etk_Tree_Row *child_row, *root_row, *message;
    Etk_Widget *messagebody;
    Etk_Widget *from_label, *to_label, *subj_label;
    Etk_Widget *status_bar;
    Etk_Widget *attachment_table;
    Etk_Tree_Col *attach_mime;
    Etk_Tree_Col *attach_size;
    Etk_Tree_Col *attach_name;
    Etk_Tree_Row *attach_row;
    Etk_Widget *attach_menu;
    Etk_Widget *attach_menu_item;
    Etk_Widget *filechooser_dialog;
    Etk_Widget *filechooser_vbox;
    Etk_Widget *filechooser_hbox;
    Etk_Widget *filechooser;
    const char *stock_key;
    /* Message currently viewed */
    MsgInfo *msginfo;
    char *file;
} Main_Gui;

/* Create and show widgets */
void build_main_gui(void);
void build_attachment_popup_menu(MimeInfo *mimeinfo);

/* Main Callbacks */
void _main_quit_cb(void *data);
void _row_clicked_cb(Etk_Tree *tree, Etk_Tree_Row *row, void *data);
void _message_clicked_cb(Etk_Tree *tree, Etk_Tree_Row *row, void *data);
void _mime_message_part_clicked_cb(Etk_Tree *tree, Etk_Tree_Row *row, Etk_Event_Mouse_Up *event, void *data);
void _mime_message_part_open_cb(Etk_Menu_Item *item, void *data);
void _mime_message_part_save_as_cb(Etk_Menu_Item *item, void *data);
void _mime_message_part_save_as(void *data);
void _mime_message_part_save_as_dialog_destroy(void *data);
void _confirm_dialog_response_cb(Etk_Object *obj, int response_id, void *data);
void _commprefs_open_cb();
int _etk_tree_compare_cb(Etk_Tree_Col *col, Etk_Tree_Row *row1, Etk_Tree_Row *row2, void *data);
//void _mime_message_part_display_text_cb(Etk_Menu_Item *item, void *data);

/* Not really a callbacks, but related to widgets */
void fill_attachment_table(MimeInfo *mimeinfo);
void list_folders(void);
gboolean traverse_func(GNode *node, gpointer data);
void list_messages(const gchar *folder_id);

extern Main_Gui *main_gui;

#endif /*MAIN_GUI_H_*/
